package ProjectViewer.Window;

import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class Window_OpcodeView extends JInternalFrame {

	private static final long serialVersionUID = 6812075350367556737L;

	public Window_OpcodeView() {
		super("Opcode", false, false, false, true);
		setSize(600,200);
		buildOpcodeTable();
		setVisible(true);
	}

	void buildOpcodeTable() {
		String columnNames[] = {"Code", "Name", "before","after"};
		Object[][] data = new Object[Opcode.values().length][4];
		
		int i=0;
		for (Opcode opcode : Opcode.values()) {
			data[i][0] = "0x" + String.format("%02x", opcode.ordinal());
			data[i][1] = opcode.getName();
			data[i][2] = opcode.getStackBefore();
			data[i][3] = opcode.getStackAfter();
			i++;
		}
		
		JTable table = new JTable(data, columnNames);
		this.getContentPane().add(new JScrollPane(table));
	}
	
}
